<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="个人资料" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="compellation">
				<text>姓名</text>
				<u-input v-model="compellation_content" style="margin-left:200rpx; width: 200rpx;" :type="type"
					placeholder="单行输入" :border="border" input-align="right" />
			</view>
			<view class="phone">
				<text>电话</text>
				<u-input v-model="phone_content" style="margin-left:200rpx; width: 200rpx;" :type="type"
					placeholder="单行输入" :border="border" input-align="right" />
			</view>
			<view class="number">
				<text>手机号</text>
				<u-input v-model="number_content" style="margin-left:200rpx; width: 200rpx;" :type="type"
					placeholder="单行输入" :border="border" input-align="right" />
			</view>
			<view class="mailbox">
				<text>Email</text>
				<u-input v-model="mail_content" style="margin-left:200rpx; width: 200rpx;" :type="type"
					placeholder="单行输入" :border="border" input-align="right" />
			</view>
			<view class="wechat">
				<text>微信号</text>
				<u-input v-model="wechat_content" style="margin-left:200rpx; width: 200rpx;" :type="type"
					placeholder="单行输入" :border="border" input-align="right" />
			</view>
			<view class="qq">
				<text>QQ号</text>
				<u-input v-model="qq_content" style="margin-left:200rpx; width: 200rpx;" :type="type" placeholder="单行输入"
					:border="border" input-align="right" />
			</view>
			<view class="address">
				地址
			</view>
			<view class=""
				style="width:94%; height:15rpx; margin-left:3%; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="input_content" placeholder="单行输入"
				style="width:94%; height:160rpx; margin-left:3%; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="" style="width:100%; height:30rpx;">
			</view>
		</view>
		<view class="confirm">
			<view class="verify" @click="alterMyInfo">
				{{verify}}
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	export default {
		data() {
			return {
				type: 'text',
				border: false,
				compellation_content: '',
				phone_content: '',
				wechat_content: '',
				qq_content: '',
				mail_content: '',
				number_content: '',
				input_content: '',
				boolen: false,
				verify: '确认修改',
			}
		},
		onLoad() {
			this.getMyInfo();
		},
		methods: {
			getMyInfo() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/user/getMyInfo',
					method: 'post',
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							let {
								full_name,
								phone,
								email,
								wechat,
								qq,
								address
							} = res.data.data;
							_this.compellation_content = full_name;
							_this.phone_content = phone;
							_this.number_content = phone;
							_this.mail_content = email;
							_this.wechat_content = wechat;
							_this.qq_content = qq;
							_this.input_content = address;
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
			alterMyInfo() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/user/updateMyInfo',
					data: {
						full_name: _this.compellation_content,
						address: _this.input_content,
						email: _this.mail_content,
						wechat: _this.wechat_content,
						qq: _this.qq_content,
					},
					method: 'post',
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data);
							_this.$toLink('../profile/profile', {},3);
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			}
		}

	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		background-color: #F2F2F2;
		height: 100vh;

		.list {
			background-color: #fff;
			margin-top: 20rpx;
			width: 710rpx;
			margin-left: 20rpx;
			border-radius: 12rpx;

			.compellation {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}

			}

			.phone {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}

			}

			.available {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}

			}

			.number {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}

			}

			.mailbox {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}
			}

			.wechat {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}
			}

			.qq {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}
			}

			.address {
				width: 94%;
				height: 78rpx;
				margin-left: 3%;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				font-size: 26rpx;
				color: #666666;
			}
		}

		.confirm {
			width: 100%;
			height: 400rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}
		}
	}
</style>
